/**
 * 
 */
package br.com.ema.maze.factory;

import br.com.ema.maze.components.Maze;
import br.com.ema.maze.components.MazeSpace;
import br.com.ema.maze.enums.Direction;

/**
 * @author Emanuel Cruz Rodrigues -> emanuelcruzrodrigues@gmail.com
 *
 */
public class MazeNearbyUpdater {

	public void updateNearby(Maze maze) {
		int height = maze.getHeight();
		int width = maze.getWidth();
		
		for (int y = 0; y < height; y++) {
			for (int x = 0; x < width; x++) {
				MazeSpace space = maze.getSpace( x, y );
				if (space != null){
					space.addNearbySpace(maze.getSpace(x, y-1), Direction.NORTH);
					space.addNearbySpace(maze.getSpace(x, y+1), Direction.SOUTH);
					space.addNearbySpace(maze.getSpace(x+1, y), Direction.EAST);
					space.addNearbySpace(maze.getSpace(x-1, y), Direction.WEST);
				}
			}
		}
	}

	
}
